﻿using System;
using System.Collections.Generic;
using UnityEngine;

namespace H
{
	// Token: 0x02000262 RID: 610
	internal class H_State_InsertedWait : H_State
	{
		// Token: 0x06001010 RID: 4112 RVA: 0x000670BC File Offset: 0x000652BC
		public H_State_InsertedWait(H_Members members) : base(members)
		{
		}

		// Token: 0x06001011 RID: 4113 RVA: 0x000670C8 File Offset: 0x000652C8
		public override void In(H_State.Message msg)
		{
			float transitionDuration = 0.2f;
			if ((this.members.StyleData.detailFlag & 4096) != 0)
			{
				transitionDuration = 0f;
			}
			this.members.PlayAnime("InsertedWait", transitionDuration);
			this.leave = false;
			this.leaveTimer = 0f;
			this.endInVoice = false;
			this.members.MaleExpression(H_Expression_Male.TYPE.NORMAL);
		}

		// Token: 0x06001012 RID: 4114 RVA: 0x00067134 File Offset: 0x00065334
		public override void Main()
		{
			this.leaveTimer += Time.deltaTime;
			if (!this.leave && this.leaveTimer >= 10f)
			{
				int femaleNo = UnityEngine.Random.Range(0, this.members.GetFemales().Count);
				this.members.VoiceExpression(femaleNo, H_Voice.TYPE.LEAVING);
				this.leave = true;
			}
			this.UpdateVoice();
			if (this.endInVoice && this.members.h_scene.MixCtrl.mode == MixController.MODE.FULL_AUTO)
			{
				base.ChangeState(H_STATE.LOOP);
			}
		}

		// Token: 0x06001013 RID: 4115 RVA: 0x000671D0 File Offset: 0x000653D0
		private void UpdateVoice()
		{
			List<Female> females = this.members.GetFemales();
			for (int i = 0; i < females.Count; i++)
			{
				if (!females[i].IsVoicePlaying())
				{
					this.members.VoiceExpression(i, H_Voice.TYPE.BREATH);
					this.endInVoice = true;
				}
			}
		}

		// Token: 0x06001014 RID: 4116 RVA: 0x00067228 File Offset: 0x00065428
		public override void OnInput(H_INPUT input)
		{
			if (input == H_INPUT.CLICK_PAD)
			{
				base.ChangeState(H_STATE.LOOP);
			}
		}

		// Token: 0x0400115F RID: 4447
		private const float leaveTime = 10f;

		// Token: 0x04001160 RID: 4448
		private float leaveTimer;

		// Token: 0x04001161 RID: 4449
		private bool leave;

		// Token: 0x04001162 RID: 4450
		private bool endInVoice;
	}
}
